<?php
	include("head.php");
	include_once("paging_function.php");
////////////////////////////////////////////    Block_---- DELETE  ///////////
if(isset($_POST['Submit']))
{
	//echo "<script>alert('helloooo');</script>";
 	$del=$_POST['del'];
 	$no=count($del);
 	if($no>0)
 	{
 	for($i=0;$i<$no;$i++)
 	{
 	   mysql_query("DELETE FROM network_clicks_purchase  WHERE Id= '".$del[$i]."' ");	   
 	}
 	echo '<script>window.location="display_network_costs.php?dlt=1"</script>';
 	}
	
	
}
//////////////////////// Block Delete Ends /////////////////////////////////
if($_REQUEST['action']=='edit')
{
	edit_network_cost();
}
else if($_REQUEST['action']=='update')
{
	update_network_cost();
}
else if($_REQUEST['action']=='delete')
{
	delete_network_cost();
}
else
{
	main();
}
// 	if($_REQUEST['mode']=='display_network_costs')
// 	{
// 		//echo "<script>alert('hi456');</script>";
// 		main();
// 	}
?>
<script>
function changeUrl(indexalpha)
{
var url='display_network_costs.php?index='+indexalpha;
window.location=url;
}

function update()
{
	if(document.edit.no_clicks.value.search(/\S/) == -1)
	{

		//alert("Please! Enter No. Of Clicks.");
		document.getElementById('alert_msg').innerHTML="Please! Enter No. Of Clicks.";

		//document.edit.no_clicks.focus();

		return false;

	}

	if(isNaN(document.edit.no_clicks.value))
	{

		//alert("Please! Enter The Numeric Value.");
		document.getElementById('alert_msg').innerHTML="Please! Enter No. Of Clicks. As Numeric Value";

		//document.edit.no_clicks.focus();

		return false;

	}

	if(document.edit.cpc.value.search(/\S/) == -1)
	{

		//alert("Please! Enter CPC.");
		document.getElementById('alert_msg').innerHTML="Please! Enter CPC.";

		//document.edit.cpc.focus();

		return false;

	}

	if(isNaN(document.edit.cpc.value))
	{

		//alert("Please! Enter CPC. As Numeric");
		document.getElementById('alert_msg').innerHTML="Please! Enter CPC. As Numeric";

		//document.edit.cpc.focus();

		return false;

	}
	document.edit.action.value='update';
	document.edit.submit();
}

</script>
<?php
function main()
{
$SQL_network_cost_details="select * from network_clicks_purchase";

/////////////////////////////////PAGING /////////////////
 	if(isset($_GET['page']) && $_GET['page']!='')
		{
		
			$page = $_GET['page'];
		}
	else
		{
			$page = 0;
		}
$limit=2;

$SQL_network_cost_details=$SQL_network_cost_details." limit $page,$limit";
//echo $SQL_network_cost_details;
$EXE_network_cost_details=mysql_query($SQL_network_cost_details) or die('error1'.mysql_error());
/////////////////////////////////////////////////////////////////	
?>
<table width="100%" border="0" cellspacing="0" cellpadding="3"  style="border:1px solid #666666">

 <tr><td>&nbsp;</td></tr>

 <tr><td>&nbsp;</td></tr>

 <tr><td>
 <table width="100%" border="0" cellspacing="0" cellpadding="3">
 <tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr> 
			<td height="15" colspan="2" align="center" style="color:#000000;font-size:12px;">
				<font color="#000000"><strong> NETWORK  MANAGEMENT </strong></font>
			</td> 
		</tr>
</table>



<table width="100%" border="0" cellspacing="0" cellpadding="3" class="tabbod">

<?php

  if(mysql_num_rows($EXE_network_cost_details)>0)
  	{
	
	?><form name="form_admin_management" action="" method="post">
		<input type="hidden" name="mode" value="">
		<tr bgcolor="#6F8DBC">
			<td width="6%" height="28" style="color:#ffffff;font-size:12px;"><strong>Sl.No</strong></td>
			<td width="32%" align="left" valign="middle" style="color:#ffffff;font-size:12px;"><strong>No. Of Clicks</strong> </td>
			<td width="32%" valign="middle" style="color:#ffffff;font-size:12px;"><strong>CPC </strong></td>
			<td width="15%" align="center" valign="middle" style="color:#ffffff;font-size:12px;"><strong>Edit</strong></td>
			<td width="15%" align="center" valign="middle" style="color:#ffffff;font-size:12px;"><strong>Delete</strong></td>
			
	</tr>
	<?php 
			$count=0;
			$sno=1;
			$loop=0;
	while($row_network_cost_details=mysql_fetch_array($EXE_network_cost_details))
		{
			$loop++;
			if($loop == 1)
			$bgcolor = "#F0F0FF";
			else 
			$bgcolor = "#CCCCFF";
	?>
		<tr bgcolor="<?php echo $bgcolor; ?>">
			<td height="32" style="color:#000000;font-size:12px;"><strong><?php echo $sno;//echo $searcharray['usercode']; ?></strong></td>
			<td align="left" valign="middle" style="color:#000000;font-size:12px;"><?php echo ($row_network_cost_details['noOfClicks']); ?></td>
			<td align="left" valign="middle" style="color:#000000;font-size:12px;"><?php echo ($row_network_cost_details['cpc']); ?></td>
			<td align="center" valign="middle"><a href="display_network_costs.php?action=edit&networkId=<?php echo $row_network_cost_details['Id'];?>" ><img src="images/edit_icon.gif" border="0"/></a></td>
			<td align="center" valign="middle"><input type="checkbox" name="del[]" value="<?php echo $row_network_cost_details['Id'];?>"></td>
		</tr>
			<?php 
			$count++;
			$sno++;
			if($loop == 2)
				{
				$loop = 0;
				}	
		}
			?>
		<tr>
			<td colspan="3">&nbsp;</td>
			<td colspan="4" align="right"><input type="hidden" name="count_UPDATE" value="<?php echo $count; ?>">
			<input type="Submit" name="Submit" value="Update"></td>
		</tr>
		<tr>
			<td colspan="7" align="center" style="color:#FF0000"><?php echo paging($SQL_network_cost_details,$page,2,'',$param);?></td>
		</tr>
		<?php
	
	}
	
	else
	
	{
	
	?>
	<tr bgcolor="#6F8DBC">
		<td width="6%" style="color:#ffffff;font-size:12px;"><strong>Sl.No</strong></td>
		<td width="32%" align="center" style="color:#ffffff;font-size:12px;"><strong>No. Of Clicks</strong></td>
		<td width="32%" align="center" style="color:#ffffff;font-size:12px;"><strong>CPC</strong></td>
		<td width="15%" align="center" style="color:#ffffff;font-size:12px;"><strong>Edit</strong></td>
		<td width="15%" align="center" style="color:#ffffff;font-size:12px;"><strong>Delete</strong></td>
      </tr>
    <tr>
      <td colspan="7" align="left">&nbsp;&nbsp;&nbsp;<strong><font color="#FF0000" class="DISPLAYMESSAGES">No Result Found!</font></strong></td>
    </tr>
    <?php

  	}

  ?>
</form>
  </table>
  </td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}
?>
<?php
function edit_network_cost()
{
$network_id=$_REQUEST['networkId'];

$SQL_edit_network_cost="select * from network_clicks_purchase where Id = '".$network_id."'";
$EXE_edit_network_cost=mysql_query($SQL_edit_network_cost);
$ROW_edit_network_cost=mysql_fetch_array($EXE_edit_network_cost);
?>

<table width="100%" border="0" cellspacing="0" cellpadding="3"  style="border:1px solid #666666">

 <tr><td>&nbsp;</td></tr>

 <tr><td>&nbsp;</td></tr>

 <tr><td>
 <table width="100%" border="0" cellspacing="0" cellpadding="3">
 <tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr> 
			<td height="15" colspan="2" align="center" style="color:#000000;font-size:12px;">
				<font color="#000000"><strong> NETWORK  MANAGEMENT </strong></font>
			</td> 
		</tr>
</table>



<!--<table width="100%" border="0" cellspacing="0" cellpadding="3" class="tabbod">-->

<?php


	
	?><form name="edit" action="" method="POST" onSubmit="return check();" >
		<input type="hidden" name="action" value="">
		<input type="hidden" name="networkId" value="<?php echo $network_id; ?>">
		<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
			<tr>
				<td width="17%" align="left">&nbsp;</td>
				<td width="2%" align="left">&nbsp;</td>
				<td width="81%" align="left" id="alert_msg"></td>
			</tr>
			<tr>
				<td width="17%" align="left" id="admin_text">No Of Clicks</td>
				<td width="2%" align="left">::</td>
				<td width="81%" align="left"><input type="text" name="no_clicks" value="<?php echo $ROW_edit_network_cost['noOfClicks'];?>" ></td>
			</tr>
			<tr>
				<td width="17%" align="left" id="admin_text">CPC</td>
				<td width="2%" align="left">::</td>
				<td width="81%" align="left"><input type="text" name="cpc" value="<?php echo $ROW_edit_network_cost['cpc'];?>" ></td>
			</tr>

			<tr>
				<td align="center">
				&nbsp;</td>
				<td align="center">&nbsp;</td>
				<td align="left"><input type="button" name="submit1" value="<?php echo UPDATE; ?>" onclick="update()" />
				&nbsp;
				<input type="button" value="Close" name="close_frm" id="close_frm" onClick="window.location='display_network_costs.php'" /></td>
			</tr>
		</table>
	</form>
 <!-- </table>-->
  </td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}

function update_network_cost()
{
	//echo "<script>alert('hiiii');</script>";
	$update_network_id=$_REQUEST['networkId'];
	$SQL_update_network_cost="update network_clicks_purchase set noOfClicks = '".$_REQUEST['no_clicks']."', cpc = '".$_REQUEST['cpc']."' where Id = '".$update_network_id."'";
	mysql_query($SQL_update_network_cost);
	main();
} 

function delete_network_cost()
{
	$del=$_POST['del'];
	$no=count($del);
	if($no>0)
	{
	for($i=0;$i<$no;$i++)
	{
	   mysql_query("DELETE FROM ".NETWORKMASTER."  WHERE networkId= '".$del[$i]."' ");	   
	}
	//echo '<script>window.location="display_network_costs.php?dlt=1"</script>';
	main();
	}
	
	
}


include("foot.php");?>